package com.bd.scm.module.expend.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.scm.dao.mapper.expend.QywxConsumeRecordMapper;
import com.bd.scm.domain.dto.expend.QywxConsumeRecordDto;
import com.bd.scm.domain.models.expend.QywxConsumeRecord;
import com.bd.scm.module.common.BaseServiceImpl;
import com.bd.scm.module.expend.service.QywxConsumeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**企业微信 消费记录ServiceImpl
 * @ClassName QywxConsumeRecordServiceImpl
 * @Description TODO
 * @Author YH
 * @Date 2020/3/25 0025 14:17
 * @Version 1.0
 **/
@Service
public class QywxConsumeRecordServiceImpl extends BaseServiceImpl<QywxConsumeRecordMapper, QywxConsumeRecord> implements QywxConsumeRecordService {

  @Autowired
  private QywxConsumeRecordMapper qywxConsumeRecordMapper;

  /**
   * 获取个人消费列表
   * @param page                  分页信息
   * @param qywxConsumeRecordDto 查询条件  人员ID userSerial 开始日期 startDate 结束日期 endDate
   * @return
   */
  @Override
  public IPage<QywxConsumeRecord> getPersonalConsumeList(Page<QywxConsumeRecord> page, QywxConsumeRecordDto qywxConsumeRecordDto) {
    OrderItem[] orderItems = new OrderItem[4];
    orderItems[0] = OrderItem.asc("dep_no");
    orderItems[1] = OrderItem.asc("userNo");
    orderItems[2] = OrderItem.asc("card_serial");
    orderItems[3] = OrderItem.asc("jl_count");
    page.addOrder(orderItems);
    return this.qywxConsumeRecordMapper.getPersonalConsumeList(page,qywxConsumeRecordDto);
  }

  /**
   * 获取个人充值列表
   * @param page                  分页信息
   * @param qywxConsumeRecordDto 查询条件  人员ID userSerial 开始日期 startDate 结束日期 endDate
   * @return
   */
  @Override
  public IPage<QywxConsumeRecord> getPersonalRechargeList(Page<QywxConsumeRecord> page, QywxConsumeRecordDto qywxConsumeRecordDto) {
    OrderItem[] orderItems = new OrderItem[3];
    orderItems[0] = OrderItem.desc("user_dep");
    orderItems[1] = OrderItem.desc("user_no");
    orderItems[2] = OrderItem.desc("sj");
    page.addOrder(orderItems);
    return this.qywxConsumeRecordMapper.getPersonalRechargeList(page,qywxConsumeRecordDto);
  }

  /**
   * 获取个人补贴列表
   * @param page                  分页信息
   * @param qywxConsumeRecordDto 查询条件  人员ID userSerial 开始日期 startDate 结束日期 endDate
   * @return
   */
  @Override
  public IPage<QywxConsumeRecord> getPersonalSubsidyList(Page<QywxConsumeRecord> page, QywxConsumeRecordDto qywxConsumeRecordDto) {
    OrderItem[] orderItems = new OrderItem[2];
    orderItems[0] = OrderItem.asc("dep_no");
    orderItems[1] = OrderItem.asc("user_no");
    page.addOrder(orderItems);
    return this.qywxConsumeRecordMapper.getPersonalSubsidyList(page,qywxConsumeRecordDto);
  }
}
